package javaEEBasic.day05;

import java.math.BigDecimal;
import java.util.Scanner;

public class Test01 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("-----订单创建中----");
        System.out.println("1.添加商品信息,2.删除商品,3.计算总价,4.当前订单信息展示，5.退出系统");
        boolean isRunning = true;
        GoodsOrder order = new GoodsOrder();
        while (isRunning) {
            System.out.println("请输入您的选择：");
            int choice = sc.nextInt();
            switch (choice) {
                case 1:
                    System.out.println("请输入商品编号：");
                    String id = sc.next();
                    System.out.println("请输入商品名称：");
                    String name = sc.next();
                    System.out.println("请输入商品价格：");
                    BigDecimal price = sc.nextBigDecimal();
                    order.addGoods(new Goods(id, price, name));
                    System.out.println("添加成功！");
                    break;
                case 2:
                    System.out.println("请输入要删除的商品编号：");
                    String deleteId = sc.next();
                    order.deleteGoods(deleteId);
                    System.out.println("删除成功！");
                    System.out.println("目前订单中商品信息:");
                    order.printGoodsList();
                    break;
                case 3:
                    order.calculateTotalPrice();
                    System.out.println("订单总价为：" + order.getTotalPrice());
                    break;
                case 4:
                    System.out.println("订单详情如下：");
                    order.printGoodsList();
                    break;
                case 5:
                    isRunning = false;
                    break;
                default:
                    System.out.println("输入错误！请重新输入！");
                    break;
            }
        }
    }
}
